package org.example.prototypePattern;

/**
 * @BelongsProject: javaFoundation
 * @BelongsPackage: org.example.prototypePattern
 * @Author: dtq
 * @CreateTime: 2023-12-14  16:41
 * @Description: 原型模式中深拷贝的使用
 * @Version: 1.0
 */
public class DeepClone {
    public static void main(String[] args) {
        TeacherSecond teacher1 = new TeacherSecond();
        teacher1.setIdNo("001");
        teacher1.setName("teacher_001");

        StudentSecond student1 = new StudentSecond();
        student1.setIdNo("101");
        student1.setName("student_101");
        student1.setTeacherSecond(teacher1);

        StudentSecond cloneStudent = student1.clone();

        System.out.println("---------------------------");
        System.out.println(student1.hashCode());
        System.out.println("idNo = " + student1.getIdNo());
        System.out.println("name = " + student1.getName());
        System.out.println("teacher = " + student1.getTeacherSecond());

        System.out.println("---------------------------");
        System.out.println(cloneStudent.hashCode());
        System.out.println("idNo = " + cloneStudent.getIdNo());
        System.out.println("name = " + cloneStudent.getName());
        System.out.println("teacher = " + cloneStudent.getTeacherSecond());
    }
}
